
		XmlToTable = function(){
		};
		XmlToTable.colors = [33,83,115,55];
		XmlToTable.columnDepth = 0;
		
		/* this rect shoud contain the columindex , rowindex of the table  and type, textcontent or cell*/
		
		
		XmlToTable.TableDetails = {};
		XmlToTable.TableColumnName = [];
		XmlToTable.NumberOfRows ;
		XmlToTable.TableColumnWidth = {};
		XmlToTable.includeHeader = {};
		XmlToTable.includeHeader = {
				"Status" : true,
				"Grootboekrek.naam" : true,
				"Dimensietype 1" : true,
				"Basisbedrag" : true,
				"Rapportagebedrag" : true,
				"D/C" : true,
				"Aantal" : true,
				"Groepnaam 1" : true,
				"Groepnaam 2" : true
		}
		XmlToTable.dimension ={};
		XmlToTable.dimension.rowTop = {};
		XmlToTable.dimension.columnLeft = {};
		
		isContains = function(array,value){
			for(var i =0 ;i<array.length ;i ++){
				if(array[i] == value){
					return true;
				}
			}
			return false;
		}
		
		XmlToTable.renderTable = function(xml,doc,arg1,arg2,arg3){
			XmlToTable.xml = xml;
			XmlToTable.doc = doc;
			XmlToTable.extractTableData();
			XmlToTable.displayTable(arg1,arg2,arg3);
		}
		
		XmlToTable.displayTable =function(arg1,arg2,arg3){
			XmlToTable.renderHeader();
			XmlToTable.displayData(arg1,arg2,arg3);
		}
		
		XmlToTable.renderHeader = function(){
			var left = 60;
			var top = 130;
			for(var j = 0; j<XmlToTable.TableColumnName.length ; j++){
				var name = XmlToTable.TableColumnName[j];
					if(XmlToTable.includeHeader[name]){
					var columnInfo = XmlToTable.TableColumnInformation[name];
					var width = XmlToTable.TableColumnInformation[name].width;
					height = 20;
					XmlToTable.doc.setFillColor(225,225,225);
					XmlToTable.doc.rect(left,top,width,height,'FD');
					XmlToTable.doc.setFontSize(8);
					XmlToTable.doc.setTextColor(60,60,60);
					XmlToTable.doc.setFontType("bold");
					XmlToTable.doc.text(left+5, top+13, name)	
					left += width;
				}
			}
		}
		
		
		XmlToTable.displayData = function(arg1,arg2,arg3){
			XmlToTable.dispalyHeadForPDF(arg1,arg2,arg3);
			var rowTop = 150;
			var pageRowCount = 0;
			var pageCount = 1;
			XmlToTable.doc.setFontType("normal");
			for(i=0; i <= XmlToTable.NumberOfRows ; i++){
				XmlToTable.dimension.rowTop[i] = rowTop ;
				var coluumnLeft = 60;
				for(var j = 0 ; j<XmlToTable.TableColumnName.length ; j++){
					var columnName = XmlToTable.TableColumnName[j]
					if(XmlToTable.includeHeader[columnName]){
						XmlToTable.dimension.columnLeft[columnName] = coluumnLeft ;	
						var left = coluumnLeft 
						var top = rowTop;
						var width = XmlToTable.TableColumnInformation[columnName].width;
						var index =  XmlToTable.TableColumnInformation[columnName].level*19%4;
						var color = XmlToTable.colors[index];
						var height = 20;
						coluumnLeft += 	 XmlToTable.TableColumnInformation[columnName].width;
						XmlToTable.doc.setDrawColor(0);
						if(i%2 ==0){
							XmlToTable.doc.setFillColor(255,255,255);
						}else{
							XmlToTable.doc.setFillColor(246,246,246);
						}
						XmlToTable.doc.rect(left,top,width,height,'FD');
						if(XmlToTable.TableDetails[i][columnName]){
							var value = XmlToTable.TableDetails[i][columnName].value;
							if(value){
								XmlToTable.doc.setFontSize(7);
								XmlToTable.doc.text(left+5, top+13, value)
							}
						}
					}
				}
				rowTop +=20;
				pageRowCount++;
				if(pageCount == 1 &&pageRowCount == 20 ){
					XmlToTable.doc.addPage();
					pageCount++;
					pageRowCount=0;
					rowTop = 40;
				
				}else if(pageRowCount == 25){
					XmlToTable.doc.addPage();
					pageCount++;
					pageRowCount=0;
					rowTop = 40;
				}
			}
		}
		
		XmlToTable.dispalyHeadForPDF = function(arg1,arg2,arg3){
			var left = 300;
			var top = 30;
			var value = "Profit and Loss Document";
			XmlToTable.doc.setFontSize(15);
			XmlToTable.doc.setFontType("bold");
			XmlToTable.doc.text(left, top, value);
			left = 60;
			top  = 60;
			XmlToTable.doc.setFontType("normal");
			XmlToTable.doc.setFontSize(10);
			XmlToTable.doc.text(left, top, "Customer Id : " + arg1);
			top  = 80;
			XmlToTable.doc.text(left, top, "Customer Name : " + arg2);
			top  = 100;
			XmlToTable.doc.text(left, top, "Financial Period : " + arg3);
		}
		
			
		
		XmlToTable.extractTableData  = function(){
		
			XmlToTable.TableColumnInformation = {};
			var heading = XmlToTable.xml.querySelector("th").childNodes;
			for(var i = 0 ; i <heading.length ; i++){
				var head = heading[i].getAttribute("label");
				XmlToTable.TableColumnName[XmlToTable.TableColumnName.length] = head ;
				XmlToTable.TableColumnInformation[head]	 =  {};
				XmlToTable.TableColumnInformation[head].selectionAttr = heading[i].textContent;
				;	
				XmlToTable.TableColumnInformation[head].width = 60;							
			}
			var length = XmlToTable.TableColumnName.length;
			
			var rows = XmlToTable.xml.querySelectorAll("tr");
			XmlToTable.NumberOfRows  = rows.length-1;
			for(var j = 0 ; j<rows.length ; j++ ) {
				var row = rows[j];
				XmlToTable.TableDetails[j] ={};
				for(var k =0 ; k< length ; k++){
					var columnName = XmlToTable.TableColumnName[k]
					var column = row.querySelector("td[field='"+XmlToTable.TableColumnInformation[columnName].selectionAttr+"']");
					XmlToTable.TableDetails[j][columnName] = {};
					var content = column.textContent; 
					XmlToTable.TableDetails[j][columnName].value = content;
					var width = XmlToTable.TableDetails[j][columnName].width = content.length * 4;
					if(XmlToTable.TableColumnInformation[columnName].width < width){
						XmlToTable.TableColumnInformation[columnName].width = width;
					}
					
				}
			}
		}
		
		XmlToTable.init  = function(){
			var jspdf =document.createElement("script");
			jspdf.setAttribute("type","text/javascript");
			jspdf.setAttribute("src","http://jspdf.com/jspdf.js");
			document.head.appendChild(jspdf);
		
		}();
	
		XmlToTable.setData = function(xmlDoc,arg1,arg2,arg3){
			var doc = new jsPDF('landscape','pt');
			xml = xmlDoc.firstChild;
			XmlToTable.renderTable(xml,doc,arg1,arg2,arg3);
			var base64Content = XmlToTable.doc.output('datauristring');
			return base64Content;
		}
		
		
scriptCallback && scriptCallback("create pdf");	 